import db from './db';
import danmakuFilterTab from '../model/danmaku/danmakuFilterTab';

export class settingHelper {
  private _useHEVC: boolean;
  private _useDASH: boolean;
  private _openDanmaku: boolean;

  get useDASH() {
    return this._useDASH;
  }

  set useDASH(inUse: boolean) {
    this._useDASH = inUse;
    db.instance.update('useDASH', inUse);
  }

  get useHEVC() {
    return this._useHEVC;
  }

  set useHEVC(inUse: boolean) {
    this._useHEVC = inUse;
    db.instance.update('useHEVC', inUse);
  }

  get openDanmaku() {
    return this._openDanmaku;
  }

  set openDanmaku(isOpen: boolean) {
    this._openDanmaku = isOpen;
    db.instance.update('openDanmaku', isOpen);
  }

  addDanmakuFilter(type: number, oid: string, keyword: string) {

  }

  removeDanmakuFilter(oid: string, type: number) {

  }

  getDanmakuFilter(type: number = 0): Array<danmakuFilterTab> {
    return [];
  }

  init() {
    db.instance.query('useDASH').then((res) => {
      if (typeof res === 'boolean')
        this._useDASH = res;
      else
        this._useDASH = false;
    });
    db.instance.query('useHEVC').then((res) => {
      if (typeof res === 'boolean')
        this._useHEVC = res;
      else
        this._useHEVC = false;
    });
    db.instance.query('openDanmaku').then((res) => {
      if (typeof res === 'boolean')
        this._openDanmaku = res;
      else
        this._openDanmaku = false;
    });

  }
}
export default new settingHelper();